package javase.thread;

import java.sql.Time;

/**
 * 模拟抢票，多人争夺同一分资源
 * @author LiShaowen
 * @date 2020/9/4 10:49
 */
public class Ticket implements Runnable{
    private int ticketNums = 100;
    @Override
    public void run() {
        while (ticketNums>0){
            System.out.println(Thread.currentThread().getName()+"-->"+ticketNums--);
        }
    }

    public static void main(String[] args) {
        Ticket ticket = new Ticket();
        new Thread(ticket,"张三").start();
        new Thread(ticket,"李四").start();
        new Thread(ticket,"王五").start();
    }
}
